package stuManagement.dao.impl;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import stuManagement.dao.StudentDao;
import stuManagement.entity.Student;

public class StudentDaoImpl extends HibernateDaoSupport implements StudentDao {

	@Override
	public List<Student> getAll() {
		return (List<Student>) getHibernateTemplate().find("from Student");
	}

	@Override
	public void add(Student student) {
		getHibernateTemplate().save(student);
	}
	
	public static void main(String[] args) {
		ApplicationContext atx = new ClassPathXmlApplicationContext("beans.xml");
		StudentDao studenDao = (StudentDao) atx.getBean("studentDao");
		for(Student s : studenDao.getAll())
			System.out.println(s.getName());
	}

}
